﻿using MxWeiXinPF.Common;
using MxWeiXinPF.Web.UI;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

//交水费
namespace MxWeiXinPF.Web.weixin.jiaoshuifei
{
    public partial class baseinfo : WeiXinPage
    {
       public Model.JSFResultModel model=null;
       public int wid = 0;

        protected void Page_Load(object sender, EventArgs e)
        {
            string wxusername = "";
            string key = "";
            string apiurl = "";
            string consNo = MyCommFun.QueryString("consNo");

            wid = MyCommFun.RequestWid();
            string thisUrl = MyCommFun.getWebSite() + "/weixin/jiaoshuifei/baseinfo.aspx?wid=" + wid;
            OAuth2BaseProc(wid, thisUrl);


            if (wid == 0 || openid == "")
            {
                Response.Redirect("/weixin/jiaoshuifei/index.aspx?wid=" + wid);
            }

            MxWeiXinPF.BLL.shuifei_baseinfo _baseInfoBLL = new BLL.shuifei_baseinfo();
            Model.shuifei_baseinfo baseinfoModel = _baseInfoBLL.GetModelByWid(Convert.ToInt32(wid));
            if (baseinfoModel != null)
            {
                wxusername = baseinfoModel.api_UserName;
                key = baseinfoModel.api_Key;
                apiurl = baseinfoModel.api_url;
            }

            jsf_bindOne jsf = new jsf_bindOne();
            string msg=string.Empty;
            if (!string.IsNullOrEmpty(consNo))
            {
                model = jsf.GetOwnInfo(consNo, wxusername,key,apiurl, "", out msg);
                if (model!=null&&model.recordList!=null&&model.recordList.Count>0)
                {
                    HttpCookie cookie = new HttpCookie("ownDetail" + wid);
                    cookie.Value =JsonConvert.SerializeObject(model.recordList);
                    Response.Cookies.Add(cookie); 
                }
            }
        }
    }
}